<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="/static/js/jquery-2.1.4.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
<link href="/static/css/bootstrap.min.css" rel="stylesheet" />
<style>
#imgCode {
	cursor: pointer;
	width: 100%;
	height: 100%
}
</style>
<script type="text/javascript">
	$(function(){
		$("#submitBtn").click(function(){
			var loginName = $("#loginName").val();
			var password = $("#password").val();
			if(loginName == "" || password == ""){
				alert("用户名和密码不可为空");
				return;
			}
			$.post("/login",{loginName:loginName,password:password},function(data){
				if(data.code == 200){
					window.location.href = "/product/toAddProduct";
				}else{
					alert(data.msg);
				}
			});
		});
	});
	$(document).keyup(function(event){
	  if(event.keyCode ==13){
	    $("#submitBtn").trigger("click");
	  }
	});
</script>
<title>运维问题管理系统</title>
</head>
<body>
	<div class="container">
		<nav class="navbar navbar-inverse navbar-fixed-top">
			<div class="container-fluid">
				<div class="navbar-header">
					<a class="navbar-brand" href="#">运维问题管理系统</a>
				</div>
			</div>
		</nav>
		<!-- 登录表单 -->
		<div class="col-md-4 column" style="margin-left: 400px;margin-top:100px;">
			<div class="row clearfix">
				<div class="col-md-12 column">
					<c:choose>
						<c:when test="${operator != null}">
							<div class="form-group" style="text-align: center;">
								<div class="col-sm-12" style="margin-top: 30%;">
									<span>
										尊敬的
										<span style="color: red">${operator.operatorName}</span>
										，您已登录
									</span>
								</div>
							</div>
							<div class="form-group">
								<div class="col-sm-12" style="margin-top: 20%;">
									<button type="button" class="btn btn-default btn-block" onclick="window.location.href='/product/toAddProduct'">进入首页</button>
								</div>
							</div>
						</c:when>
						<c:otherwise>
							<div class="form-horizontal" role="form">
								<div id="alertDiv" class="alert alert-dismissable alert-danger" hidden="hidden">
									<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
									<span id="alertAttr" value="" />
									<span id="alertMsg"><c:if test="${msg ne null}">${msg}</c:if></span>
								</div>
								<div class="form-group">
									<div class="col-sm-12">
										<input id="loginName" name="loginName" class="form-control" type="text" placeholder="登录名" />
									</div>
								</div>
								<div class="form-group">
									<div class="col-sm-12">
										<input id="password" name="password" class="form-control" type="password" placeholder="登录密码" />
									</div>
								</div>
								<div class="form-group">
									<div class="col-sm-12">
										<button id="submitBtn" type="button" class="btn btn-default btn-block">登录</button>
									</div>
								</div>
							</div>
						</c:otherwise>
					</c:choose>
				</div>
			</div>
		</div>
	</div>
	</div>
</body>
</html>